import axios from 'axios'
import { BaseURL } from './member.js' // 获取接口
const request = axios.create({
  baseURL: BaseURL,
  timeout: 3000,
})

// 添加请求拦截器
request.interceptors.request.use(
  function (config) {
    if (localStorage.getItem('token')) {  // 配置token
      config.headers['token'] = localStorage.getItem('token')
    }
    return config
  },
  function (error) {
    return Promise.reject(error)
  }
)

// 添加响应拦截器
request.interceptors.response.use(
  function (response) {
    return response.data
  },
  function (error) {

  }
)


export default request